﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace FoodFight3D
{
    public class Foods
    {
        public Model FoodModel;
        public int Strength;
        public Vector3 position;
        public float rotationAngle;
        public Vector3 velocity;
        public bool thrown = false;
        public bool held = false;


        public Foods(Model model, int strength, float x, float y, float z)
        {
            FoodModel = model;
            Strength = strength;
            position.X = x;
            position.Y = y;
            position.Z = z;
            velocity = new Vector3(0.0f, 0.0f, 0.0f);
            rotationAngle = 0.0f;
        }

        public void update(Kathy player)
        {
            position += velocity;

            if (held)
            {
                float xAddition = (float)(Math.Sin((double)player.rotationAngle + MathHelper.ToRadians(90)) * 3);
                float zAddition = (float)(Math.Cos((double)player.rotationAngle + MathHelper.ToRadians(90)) * 3);
                float xCam = player.location.X - xAddition;
                float zCam = player.location.Z - zAddition;
                position = new Vector3(xCam, 5f, zCam);
                
            }


             
        }

        public void move()
        {
        }

        public void draw(Matrix world, Matrix view, Matrix projection)
        {
            for (int index = 0; index < FoodModel.Meshes.Count; index++)
            {
                ModelMesh mesh = FoodModel.Meshes[index];
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.PreferPerPixelLighting = true;
                    effect.EnableDefaultLighting();
                    effect.World = mesh.ParentBone.Transform * world;
                    effect.View = view;
                    effect.AmbientLightColor = new Vector3 (1f,1f,0f);  // for bananas!
                    effect.Projection = projection;
                }

                mesh.Draw();
            }

        }
    }
}
